# -*- conding:UTF-8 -*-

'''
@ Project: p7_flask
@ File: redis_client.py
@ Author: 师路遥
@ Date：2022/6/6 16:09

'''

from flask import current_app
import redis

class RedisOper():
    def __init__(self):
        host = current_app.config.get('REDIS_HOST')
        post = current_app.config.get('REDIS_POST')
        db = current_app.config.get('REDIS_DB')
        pwd = current_app.config.get('REDIS_PWD')

        self.rds = redis.Redis(host=host,port=post,db=db,password=pwd)

    def set_v(self,data,expire,value):
        self.rds.setex('data_%s'%data,expire,value)

    def get_v(self,data):
        self.rds.get('data_%s'%data)

